using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerBlackDongState : PlayerState
{
    bool isUseSkill;
    float flyTime=.4f;
    float selfGrity;

    public PlayerBlackDongState(Player player, PlayerStateMachine playerStateMachine, string animBoolName) : base(player, playerStateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        selfGrity = rb.gravityScale;
        stateTime = flyTime;
        isUseSkill = false;
        rb.gravityScale = 0; 
    }

    public override void Exit()
    {
        rb.gravityScale = selfGrity;
        player.entityFx.MakeTransParent(false);
        base.Exit();
    }

    public override void Update()
    {
        base.Update();
        if (stateTime > 0)
            rb.velocity = new Vector2(0, 15);
        else if(stateTime<0)
        {
            rb.velocity = new Vector2(0, -.1f);
            if (isUseSkill == false)
            {
                if (player.skill.blackDongSkill.CanUseSkill())
                {
                    isUseSkill = true;
                }
            }
        }
        if (player.skill.blackDongSkill.BlackDongIsFinish())
            player.playerStateMachine.ChangeState(player.playerAirState);
    }
}
